package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.print("请输入图书的名字：");
        int currentSize = bookList.getUesSize();
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        for (int i = 0 ; i < currentSize; i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)) {
                System.out.println("找到了！");
                System.out.println(book);
                System.out.println();
                return;
            }
        }
        System.out.println("没有这本书！");
        System.out.println();
    }
}
